package com.mall.web.controller.mall;

import com.mall.common.core.controller.BaseController;
import com.mall.common.core.domain.Ztree;
import com.mall.product.domain.biz.ProBrandRecommendedBiz;
import com.mall.product.domain.biz.ProCategoryBiz;
import com.mall.product.domain.biz.ProProductNewBiz;
import com.mall.product.domain.biz.ProProductRecommendedBiz;
import com.mall.product.domain.entity.ProBrand;
import com.mall.product.service.*;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by zhonglin on 2020/4/29.
 */
@Controller
@RequestMapping("/mall")
public class MallIndexController
    extends BaseController {

  @Autowired
  private ProCategoryService proCategoryService;
  @Autowired
  private ProBrandService            proBrandService;
  @Autowired
  private ProBrandRecommendedService proBrandRecommendedService;
  @Autowired
  private ProProductRecommendedService proProductRecommendedService;
  @Autowired
  private ProProductNewService proProductNewService;

  //系统首页
  @GetMapping("/index.html")
  public String index(ModelMap mmap) {

    //分类
    ProCategoryBiz category = proCategoryService.findProCategoryTree();
    //品牌
    List<ProBrandRecommendedBiz> brands = proBrandRecommendedService.selectRecommendedBrandAll();
    //商品推荐
    List<ProProductRecommendedBiz> productRecommendeds = proProductRecommendedService.selectProProductRecommendedList(null);
    //新品推荐
    List<ProProductNewBiz> productNews = proProductNewService.selectProProductNewList(null);

    mmap.put("category", category);
    mmap.put("brands", brands);
    mmap.put("productRecommendeds", productRecommendeds);
    mmap.put("productNews", productNews);
    return "mall/index" ;
  }

}
